﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Vision.Camera.Base
{
    public interface ICamera
    {
        event EventHandler<ImageArgs> OnReceiveImg;
        string Name { get; }

        /// <summary>
        /// 读取图像
        /// </summary>
        /// <param name="millisecondsTimeout">超时时间,ms</param>
        /// <returns></returns>
        Bitmap ReadImage(int millisecondsTimeout=1000);

        /// <summary>
        /// 读取图像
        /// </summary>
        /// <param name="millisecondsTimeout"></param>
        /// <returns></returns>
        //OpenCvSharp.Mat ReadMat(int millisecondsTimeout);

        #region 连接
        /// <summary>
        /// 扫描
        /// </summary>
        List<ICamera> Scan(string brand);
        /// <summary>
        /// 打开相机
        /// </summary>
        bool OpenCam();
        /// <summary>
        /// 关闭相机
        /// </summary>
        void CloseCam();
        #endregion

        #region 触发
        /// <summary>
        /// 软触发
        /// </summary>
        /// <returns></returns>
        bool Snap();
        /// <summary>
        /// 开启连续触发
        /// </summary>
        /// <returns></returns>
        bool StartGrabbing();
        /// <summary>
        /// 停止连续触发
        /// </summary>
        /// <returns></returns>
        bool StopGrabbing();
        /// <summary>
        /// 设置硬触发
        /// </summary>
        void SetHardtrig();
        /// <summary>
        /// 复位硬触发
        /// </summary>
        void ReSetHardtrig();
        #endregion

        #region 设置
        /// <summary>
        /// 设置曝光时间
        /// </summary>
        /// <param name="value">us</param>
        void SetExposureTime(long value);
        /// <summary>
        /// 获取曝光时间
        /// </summary>
        /// <returns>us</returns>
        long GetExposureTime();
        /// <summary>
        /// 设置增益
        /// </summary>
        /// <param name="value"></param>
        void SetGain(double value);
        /// <summary>
        /// 获取增益
        /// </summary>
        /// <returns></returns>
        double GetGain();
        #endregion

    }
    public class ImageArgs : EventArgs
    {
        public Bitmap image;
        public ImageArgs(Bitmap image)
        {
            this.image = image;
        }
    }
}
